package com.maktoub.apiinterfaceproject.controller;

import com.maktoub.apiclientstart.entity.HelloGetListParam;
import com.maktoub.apiclientstart.entity.PostInputParamTest;
import com.maktoub.apiinterfaceproject.common.BaseResponse;
import com.maktoub.apiinterfaceproject.service.InterfaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * say Hello接口
 * @author maktoub
 */

@RestController
@RequestMapping("/say")
public class MainController {

    @Autowired
    InterfaceService interfaceService;

    @GetMapping("/test")
    public BaseResponse<String > testInterfaceNodata(@RequestParam(required = false) String name,HttpServletRequest request){
        return new BaseResponse<>(200,"testOk ","");

    }


    @GetMapping("/hello")
    public BaseResponse<String> sayGetList(HelloGetListParam helloGetListParam, HttpServletRequest request){
        System.out.println("helloGetListParam = " + helloGetListParam );
        BaseResponse<String> stringBaseResponse = interfaceService.sayHelloGetList(helloGetListParam, request);
        return stringBaseResponse;
    }
    @PostMapping("/hello")
    public BaseResponse<String> sayPostReqJson(@RequestBody PostInputParamTest inputParam, HttpServletRequest request){
        BaseResponse<String> s = interfaceService.sayHelloPost(inputParam, request);
        return s;

    }


}
